package com.itheima.controller;

import com.itheima.domain.OrderReturnReason;
import com.itheima.manager.OmsOrderReturnReasonManager;
import com.itheima.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OmsOrderReturnReasonController {
    @Autowired
    OmsOrderReturnReasonManager omsOrderReturnReasonManager;

    //分页查询退货原因
    @GetMapping("/returnReason/list")
    public Result list(
            @RequestParam(defaultValue = "1")Integer pageNum,
            @RequestParam(defaultValue = "5")Integer pageSize
    ){
       //调用manager完成分页查询
        return omsOrderReturnReasonManager.list(pageNum,pageSize);
    }


    //获取单个退货原因详情信息
    @GetMapping("/returnReason/{id}")
    public Result findById(@PathVariable Integer id){
        return omsOrderReturnReasonManager.findById(id);
    }


    //批量删除退货原因
    @PostMapping("/returnReason/delete")
    public Result delete(@RequestParam Integer[] ids){

        return omsOrderReturnReasonManager.delete(ids);
    }

    //添加退货原因
    @PostMapping("/returnReason/create")
    public Result add(@RequestBody OrderReturnReason omsOrderReturnReason){
        return omsOrderReturnReasonManager.add(omsOrderReturnReason);
    }

    //修改退货原因启用状态
    @PostMapping("/returnReason/update/status")
    public Result updateStatus(
            @RequestParam Integer ids,
            @RequestParam Integer status
    ){

        return omsOrderReturnReasonManager.updateStatus(ids,status);
    }

    //修改退货原因
    @PostMapping("/returnReason/update/{id}")
    public Result updateById(
            @PathVariable Integer id,
            @RequestBody OrderReturnReason omsOrderReturnReason
    ){
        return omsOrderReturnReasonManager.updateById(id,omsOrderReturnReason);
    }




}

